<template>
	<view class="doctor-container">
		<scroll-view class="scroll-view_H" scroll-y="true">
			<view class="flex flex-column align-center" style="padding-top: 70rpx;">
				<u--image width="80" height="80" :src="doctorImg" shape="circle"></u--image>
				<text class="f-bold color-323232 m-t-30 f-s-36">{{doctorName}}</text>
				<view class="flex align-center m-t-15">
					<text class="color-333 f-s-30">{{doctorTitleTrans[doctorTitle]}} {{deptName}}</text>
				</view>
				<view class="m-t-30" style="width: 94%;margin-left: 3%;">
					<view class="custom-title flex align-center">
						<view class="dot"></view>
						<text class="f-bold color-323232 f-s-32">医生简介</text>
					</view>
					<view class=" p-l-12 p-r-12 m-t-15">
						<text class="color-666 f-s-30">{{articleTitle}}</text>
					</view>
				</view>
				<view class="m-t-30" style="width: 94%;margin-left: 3%;">
					<view class="custom-title flex align-center">
						<view class="dot"></view>
						<text class="f-bold color-323232 f-s-32">介绍详情</text>
					</view>
					<view class=" p-l-12 p-r-12 m-t-15">
						<text class="color-666 f-s-30">{{articleContent}}</text>
					</view>
				</view>

			</view>
		</scroll-view>
		<view class="to-register" @click="toRegistration">
			<u-button type="primary" text="去挂号"></u-button>
		</view>
	</view>
</template>

<script>
	import config from "@/config.js";
	import {
		getDoctorDetail,getConfigKey
	} from "@/api/home/home.js";
	import {
		getDictType
	} from "@/api/system/public.js";
	export default {
		data() {
			return {
				id: '',
				articleTitle: '',
				articleContent: '',
				doctorImg: '',
				doctorName: '',
				deptName: '',
				doctorTitle: '',
				sexTrans: {},
				doctorTitleTrans: {},
				deptCode: '',
				gh: '',
			}
		},
		onLoad: function(res) {
			console.log(res)
			this.id = res.id
			this.getData()
			/* 获取字典 */
			this.getDict()
		},
		methods: {
			/* 去挂号 */
			toRegistration() {
				uni.navigateTo({
					url: '/pages/home/registration?id=' + this.id
				})
				// uni.navigateTo({
				// 	url: '/pages/mine/selectDepartment/index?registerType=1'
				// })
			},
			/* 获取医生详情 */
			getData() {
				getDoctorDetail(this.id).then(res => {
					console.log(res)
					this.deptName = res.data.deptName || ''
					this.doctorImg = res.data.doctorImg ? res.data.doctorImg : res.data.sex == '2' ? require('@/static/images/homeIndex/doct-g.png') : res.data.sex == '1' ? require(
						'@/static/images/homeIndex/doct-m.png') : require('@/static/images/homeIndex/avator-doctor.png')
					if (res.data.doctorImg) {
						// 替换域名
						let imgurl = this.doctorImg;
						let index = imgurl.indexOf('/profile');
						let urlParts = imgurl.slice(index);
						this.doctorImg = config.baseUrl + urlParts;
					}
					this.doctorName = res.data.doctorName || ''
					this.articleTitle = res.data.articleTitle || ''
					this.articleContent = res.data.articleContent || ''
					this.doctorTitle = res.data.doctorTitle || ''
					this.deptCode = res.data.deptCode
					this.gh = res.data.doctorCode
				});
			},
			/* 字典 */
			getDict() {
				getDictType({
					dictType: 'user_sex'
				}).then(res => {
					res.rows.forEach(item => {
						this.sexTrans[item.dictValue] = item.dictLabel
					})
				});
				getDictType({
					dictType: 'doctor_title'
				}).then(res => {
					res.rows.forEach(item => {
						this.doctorTitleTrans[item.dictValue] = item.dictLabel
					})
				});
			},

		}
	}
</script>

<style scoped lang="scss">
	page {
		height: 100%;

		.doctor-container {
			width: 100%;
			height: 100%;
			position: relative;
			background-color: #F6F7F9;

			.to-register {
				width: 94%;
				margin-left: 3%;
				position: absolute;
				bottom: 10rpx;
			}

			.scroll-view_H {
				width: 100%;
				height: 100%;
				padding-bottom: 100rpx;

				.custom-title {
					.dot {
						width: 10rpx;
						height: 32rpx;
						border-radius: 10rpx;
						background-color: #4D8EFF;
						margin-right: 10rpx;
					}
				}


				.avatar {
					width: 160rpx;
				}


			}

		}

	}
</style>
